<!DOCTYPE html>
<html lang="en">
<head>
    <title>添加剧本</title>

    <!-- Meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <meta name="description" content="Portal - Bootstrap 5 Admin Dashboard Template For Developers">
    <meta name="author" content="Xiaoying Riley at 3rd Wave Media">
    <link rel="shortcut icon" href="/assets/favicon.ico">

    <script defer src="/assets/js/jquery-2.1.4.js"></script>
    <!-- FontAwesome JS-->
    <script defer src="/assets/plugins/fontawesome/js/all.min.js"></script>

    <!-- App CSS -->
    <link id="theme-style" rel="stylesheet" href="/assets/css/portal.css">

</head>

<body class="app app-signup p-0">
<div class="row g-0 app-auth-wrapper">
    <div class="col-12 col-md-7 col-lg-6 auth-main-col text-center p-5">
        <div class="d-flex flex-column align-content-end">
            <div class="app-auth-body mx-auto">
                <div class="app-auth-branding mb-4">
                    <a class="app-logo" href="index">
                        <img class="logo-icon me-2" src="/assets/images/app-logo.svg" alt="logo">
                    </a>
                </div>
                <h2 class="auth-heading text-center mb-4">添加剧本</h2>
                <div class="auth-form-container text-start mx-auto">
                    <div class="auth-form auth-signup-form">
                        <div class="email mb-3">
                            <label class="sr-only" for="name">名称</label>
                            <input id="name" type="text" class="form-control signup-name"
                                   placeholder="名称" required="required">
                        </div>
                        <div class="email mb-3">
                            <label class="sr-only" for="type">类型</label>
                            <input id="type" type="text" class="form-control signup-email"
                                   placeholder="类型" required="required">
                        </div>
                        <div class="email mb-3">
                            <label class="sr-only" for="face">封面地址</label>
                            <input id="face" type="text" class="form-control signup-email"
                                   placeholder="封面地址" required="required">
                        </div>
                        <div class="email mb-3">
                            <label class="sr-only" for="content">内容</label>
                            <textarea id="content" class="form-control signup-email" style="height: 120px"
                                      placeholder="内容" required="required"></textarea>
                        </div>
                        <div class="email mb-3">
                            <label class="sr-only" for="type">价格</label>
                            <input id="price" type="number" min="1" class="form-control signup-email"
                                   placeholder="价格" required="required">
                        </div>
                        <div class="email mb-3">
                            <label class="sr-only" for="type">时间 (分钟)</label>
                            <input id="time" type="number" min="1" class="form-control signup-email"
                                   placeholder="时间 (分钟)" required="required">
                        </div>
                        <div class="email mb-3">
                            <label class="sr-only" for="type">参与人数</label>
                            <input id="people" type="number" min="1" class="form-control signup-email"
                                   placeholder="参与人数" required="required">
                        </div>
                        <div class="text-center">
                            <button onclick="add()" class="btn app-btn-primary w-100 theme-btn mx-auto">添加</button>
                        </div>
                    </div><!--//auth-form-->
                </div><!--//auth-form-container-->
            </div><!--//auth-body-->
        </div><!--//flex-column-->
    </div><!--//auth-main-col-->
    <div class="col-12 col-md-5 col-lg-6 h-100 auth-background-col">
        <div class="auth-background-holder">
        </div>
        <div class="auth-background-mask"></div>
    </div><!--//auth-background-col-->

</div><!--//row-->
<script type="text/javascript">
    function add() {
        var script = {}
        script['name'] = document.getElementById('name').value
        script['type'] = document.getElementById('type').value
        script['face'] = document.getElementById('face').value
        if (script['face'] === '') script['face'] = 'https://android-screenimgs.25pp.com/fs08/2019/01/07/1/110_38709d3793f1e32d09267b264bde7484.jpeg'
        script['content'] = document.getElementById('content').value
        script['price'] = parseInt(document.getElementById('price').value)
        script['time'] = parseInt(document.getElementById('time').value)
        script['people'] = parseInt(document.getElementById('people').value)
        script['star'] = 0
        script['played'] = 0
        script['firstPlayed'] = 0
        $.ajax({
            url: '/ms/api/script/',
            method: 'post',
            data: JSON.stringify(script),
            dataType: 'json',
            contentType: 'application/json;charset=utf-8',
            success: function (result) {
                if (result['success']) window.location = '/ms/scripts'
                else alert('添加失败')
            }
        })
    }
</script>
</body>
</html> 

